package com.movie.ticket.sale.bossassembly.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.movie.ticket.sale.bossassembly.entity.Cinema;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.movie.ticket.sale.bossassembly.pram.MovieOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author muzi
 * @since 2020-12-09
 */
public interface CinemaMapper extends BaseMapper<Cinema> {
    @Select("select id,tel,cinema_name,address,state,service,degree,illegal,chain,legal_person,annual_cost,annual_data,account,tip_root from t_cinema")
    IPage<Cinema> findCinemas(Page<Cinema> page);

    @Select("select o.id,user_id,cinema_id,name,real_price,ticket_price,tip,number,refund,create_time from t_order_movie as o left join t_movie as m on o.movie_id = m.id")
    IPage<MovieOrder> findOrders(Page<MovieOrder> page);

    @Select("select id from t_cinema where state=0")
    List<Integer> getAllApplyForEnter();

    @Update("update t_cinema set state=2 where state=0 and id=#{id}")
    void configApply(int id);
}
